function residual = static_resid(T, y, x, params, T_flag)
% function residual = static_resid(T, y, x, params, T_flag)
%
% File created by Dynare Preprocessor from .mod file
%
% Inputs:
%   T         [#temp variables by 1]  double   vector of temporary terms to be filled by function
%   y         [M_.endo_nbr by 1]      double   vector of endogenous variables in declaration order
%   x         [M_.exo_nbr by 1]       double   vector of exogenous variables in declaration order
%   params    [M_.param_nbr by 1]     double   vector of parameter values in declaration order
%                                              to evaluate the model
%   T_flag    boolean                 boolean  flag saying whether or not to calculate temporary terms
%
% Output:
%   residual
%

if T_flag
    T = model_6_IRFs.static_resid_tt(T, y, x, params);
end
residual = zeros(46, 1);
lhs = y(35);
rhs = T(1);
residual(1) = lhs - rhs;
lhs = y(37);
rhs = T(2);
residual(2) = lhs - rhs;
lhs = y(36);
rhs = T(3);
residual(3) = lhs - rhs;
lhs = y(38);
rhs = T(4);
residual(4) = lhs - rhs;
lhs = 1/y(32);
rhs = T(5)*T(6)+params(1)*(1-params(8))/y(32);
residual(5) = lhs - rhs;
lhs = 1/y(32);
rhs = T(7)*(1+y(34));
residual(6) = lhs - rhs;
lhs = y(32);
rhs = params(3)*T(8)^((params(3)-1)/params(3));
residual(7) = lhs - rhs;
lhs = y(18)^(-params(2));
rhs = params(6)/(1-params(5))/y(32);
residual(8) = lhs - rhs;
lhs = y(32)*y(40)/params(6);
rhs = y(27)*T(9)-y(28)*y(34);
residual(9) = lhs - rhs;
lhs = y(9);
rhs = 0.5*(1+erf(T(10)));
residual(10) = lhs - rhs;
lhs = y(21);
rhs = T(11);
residual(11) = lhs - rhs;
lhs = (1+y(22))*y(28)*y(9);
rhs = y(28)*y(9)*(1+y(44));
residual(12) = lhs - rhs;
lhs = 1+y(34);
rhs = (1+y(22))*(1+y(33));
residual(13) = lhs - rhs;
lhs = y(34);
rhs = y(36)*params(9)*params(10)*y(16)*(1-params(4));
residual(14) = lhs - rhs;
lhs = y(16)*y(39)*(1-params(4));
rhs = y(28)/y(27)+params(12)*(1-params(8))-(1-params(8))*(1-y(43));
residual(15) = lhs - rhs;
lhs = y(31);
rhs = y(27)*y(9)*params(10)*T(12);
residual(16) = lhs - rhs;
lhs = y(30);
rhs = y(27)*y(9)*params(10)*T(13);
residual(17) = lhs - rhs;
lhs = y(23)*(y(31)+y(30)+y(19));
rhs = y(31)+y(30);
residual(18) = lhs - rhs;
lhs = (y(31)+y(30))*y(24);
rhs = y(31);
residual(19) = lhs - rhs;
lhs = y(17);
rhs = y(27)*params(52)+y(35)*y(27)*y(9)*params(10)+y(38)*y(27)*y(9)*params(10);
residual(20) = lhs - rhs;
lhs = y(20);
rhs = y(27)+y(18)+y(45)-y(27)*(1-params(8));
residual(21) = lhs - rhs;
lhs = y(20);
rhs = y(16)*y(17)/(1-params(3));
residual(22) = lhs - rhs;
lhs = y(19);
rhs = y(27)-y(27)*(1-params(8));
residual(23) = lhs - rhs;
lhs = y(29);
rhs = y(17)*T(15);
residual(24) = lhs - rhs;
lhs = T(17)*T(18)*T(19);
rhs = y(20);
residual(25) = lhs - rhs;
lhs = y(26);
rhs = T(17);
residual(26) = lhs - rhs;
lhs = y(41);
rhs = T(20);
residual(27) = lhs - rhs;
lhs = y(42);
rhs = T(21);
residual(28) = lhs - rhs;
lhs = y(12);
rhs = log(y(32))-log((y(32)));
residual(29) = lhs - rhs;
lhs = y(8);
rhs = log(1+y(22))-log(1+(y(22)));
residual(30) = lhs - rhs;
lhs = y(14);
rhs = y(34)-(y(34));
residual(31) = lhs - rhs;
lhs = y(6);
rhs = log(y(23))-log((y(23)));
residual(32) = lhs - rhs;
lhs = y(7);
rhs = log(y(24))-log((y(24)));
residual(33) = lhs - rhs;
lhs = y(15);
rhs = log(y(25))-log((y(25)));
residual(34) = lhs - rhs;
lhs = y(5);
rhs = log(y(26))-log((y(26)));
residual(35) = lhs - rhs;
lhs = y(13);
rhs = log(y(28))-log((y(28)));
residual(36) = lhs - rhs;
lhs = y(1);
rhs = log(y(20)+y(32)*y(21)*params(15)-y(45))-log((y(20)+y(32)*y(21)*params(15)-y(45)));
residual(37) = lhs - rhs;
lhs = y(3);
rhs = log(y(19))-log((y(19)));
residual(38) = lhs - rhs;
lhs = y(2);
rhs = log(y(18)+y(32)*y(21)*params(15))-log((y(18)+y(32)*y(21)*params(15)));
residual(39) = lhs - rhs;
lhs = y(4);
rhs = log(y(21)+y(29))-log((y(21)+y(29)));
residual(40) = lhs - rhs;
lhs = y(11);
rhs = log(y(41))-log((y(41)));
residual(41) = lhs - rhs;
lhs = y(10);
rhs = log(y(42))-log((y(42)));
residual(42) = lhs - rhs;
lhs = log(y(43))-log(params(11));
rhs = (log(y(43))-log(params(11)))*params(22)+params(26)*x(1);
residual(43) = lhs - rhs;
lhs = log(1+y(44))-log(1+params(7));
rhs = (log(1+y(44))-log(1+params(7)))*params(24)-params(28)*x(3);
residual(44) = lhs - rhs;
lhs = log(y(46))-log(params(35));
rhs = (log(y(46))-log(params(35)))*params(23)+params(27)*x(2);
residual(45) = lhs - rhs;
lhs = log(y(45))-log(params(34));
rhs = (log(y(45))-log(params(34)))*params(25)+params(29)*x(4);
residual(46) = lhs - rhs;
if ~isreal(residual)
  residual = real(residual)+imag(residual).^2;
end
end
